VC Verification
1. Install
npm install @extrimian/vc-verifier
2. Verify
To verify the credential we are going to use VcVerifierService. This services receives a callback to resolve DID that you already wrote in Resolve section.
import { VCVerifierService } from "@extrimian/vc-verifier";
import { DIDModenaResolver } from "@extrimian/did-resolver";
const service = new VCVerifierService({
didDocumentResolver: async (did: string) => {
const resolver = new DIDModenaResolver({
modenaURL: getQuarkidApiURL();
});
const didDocument = await resolver.resolveDID(did.substring(did.lastIndexOf(":") + 1));
return didDocument;
}
});
We resolve the DID Document and call the verification function, which receives the credential and the purpose, which in this case is Assertion Method, used for the verification of credentials.
const result = await service.verify(vc, new AssertionMethodPurpose());
The result variable returns true if verifies correctly, or false with error resutl if verification fails.
3. Test
console.log(result);